package bishi.saijing;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2022/03/27 10:22
 */
public class _L {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        sc.nextLine();
        sc.nextLine();
        long sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += i;
        }
        long ji = sum;
        for (int i = 2; i <= n; i *= 2) {
            sum += ji * i;
        }
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            int start = sc.nextInt();
            int end = sc.nextInt();
            int value = sc.nextInt();
            int now = end - start + 1;
            int temp = value;
            for (int j = 2; j <= n; j *= 2) {
                value += temp * j;
            }
            sum += now * value;
            list.add(sum);
        }
        for (long l:list){
            System.out.println(l);
        }
    }
}
